package com.jwell.panprovider.tools;

import android.util.Log;

import com.jwell.panprovider.entity.YearBean;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

/**
 * Created by 76577 on 2018/4/2.
 * 获取当前时间的后十年与前十年
 */

public class DateUtil {

//    //二月份
//                        if(((year+i) %4==0&&(year+i) %100!=0)||(year+i) %400==0)
//
//    {
//        Log.i("TAG", (year+i) + "年是闰年。");
//        monthBean.setDayBeanList(dayBean2);
//    } else
//
//    {
//        //非闰年2月28天
//        Log.i("TAG", (year+i) + "年不是闰年。");
//    }

    public static List<YearBean> getDateData(int lateYear) {
        List<YearBean> yearBeanList = new ArrayList<>();
        Calendar calendar = Calendar.getInstance();
        int year = calendar.get(Calendar.YEAR);
        int month = calendar.get(Calendar.MONTH);
        int day = calendar.get(Calendar.DAY_OF_MONTH);
        int maxMonth = 12;
        int minMonth = 1;
        int maxDay = 31;
        for (int i = 0; i < lateYear; i++) {
            YearBean yearBean = new YearBean();
            yearBean.setYear(year + i);
            yearBean.setMaxMonth(maxMonth);
            if (i == 0) {
                yearBean.setMinMonth(month + 1);
                yearBean.setMinDay(day);
            } else {
                yearBean.setMinMonth(minMonth);
                yearBean.setMinDay(1);
            }
            //二月份
            if (((year + i) % 4 == 0 && (year + i) % 100 != 0) || (year + i) % 400 == 0) {
                //闰年2月29天
                yearBean.setDayOfMonth2(29);
                Log.i("TAG", (year + i) + "年是闰年。");
            } else

            {
                //非闰年2月28天
                yearBean.setDayOfMonth2(28);
                Log.i("TAG", (year + i) + "年不是闰年。");
            }
            yearBean.setDayOfMonth1(31);
            yearBean.setDayOfMonth3(31);
            yearBean.setDayOfMonth4(30);
            yearBean.setDayOfMonth5(31);
            yearBean.setDayOfMonth6(30);
            yearBean.setDayOfMonth7(31);
            yearBean.setDayOfMonth8(31);
            yearBean.setDayOfMonth9(30);
            yearBean.setDayOfMonth10(31);
            yearBean.setDayOfMonth11(30);
            yearBean.setDayOfMonth12(31);
            yearBeanList.add(yearBean);
        }
        return yearBeanList;
    }
}
